<!--多币对-历史记录（终止过的子币对）-->
<template>
  <div class="bg">
    
    <div class="title">
      <text class="font24 text3">{{T("交易对")}}</text>
      <div class="all"></div>
      <text class="font24 text3">{{T("总收益")+ '(' + investCoin + ')'}}</text>
    </div>

    <!-- 列表 -->
    <div class="line bg3"></div>
    <list class="list">
    
      <!--刷新-->
      <refresh class="refresh" @refresh="httpChildRecord" :display="isRefresh ? 'show' : 'hide'">
        <loading-indicator class="load text1"></loading-indicator>
      </refresh>

      <!--内容-->
      <cell v-for="(item, index) in datas" v-bind:key="index">

        <div class="cell" v-if="item.executeId" @click="itemClick(item.executeId)">
          <text class="font28 text2">{{item.counterCoin + "/" + item.baseCoin + "(" + item.count + ")"}}</text>
          <div class="all"></div>
          <text class="font28 text1">{{item.realEarnings}}</text>
          <LImage class="image-arrow" :src="Config.img('strategy_arrow.png')"></LImage>
        </div>

        <div class="genduo-bg" v-else>
          <text class="font22 text3">{{T('没有更多数据')}}</text>
        </div>
      </cell>
    </list>
  </div>
</template>

<script>
import navigator from "@/_js/navigator";
import modal from "@/_js/modal";
import math from "@/_js/math";
import Config from "@/_js/config";

import weexHttp from "@/_js/https"; ;
const weexFunction = weex.requireModule("WeexFunction");

import I18N from "@/_i18n/i18n";
var T = I18N.t;
weexFunction.setTitle(T("历史记录"));

export default {

  data() {
    return {
      T: T,
      Config:Config,
      math: math,
      isRefresh:false, //turn 刷新

      executeId:'', //执行Id
      investCoin:'' , //投资币
      
      datas:[], //历史列表
    };
  },

  mounted() {

    this.executeId = navigator.getParam("executeId");
    this.investCoin = navigator.getParam("investCoin");

    this.httpChildRecord();
  },

  methods: {
    /********************************** HTTP*/
    //历史列表
    httpChildRecord() {

      if (this.isRefresh) return;
      this.isRefresh = true;

      var param = {'executeId':this.executeId};
      weexHttp.post("strategyV3/sonExecuteHistoryList",param,true,(data) => {

          this.isRefresh = false;
          if (data.status == 200) {
            data = data.data;

            var datas = data.sonExecuteHistoryList;
            var length = math.getCoin(this.investCoin);
            for (let i = 0; i < datas.length; i++) {
              var pair = datas[i];
              pair.realEarnings = math.xiaoshu(pair.realEarnings, length, 2);
            }
            datas = datas ? datas : [];
            datas.push({});
            this.datas = datas;
          } else {
            modal.toast(data.msg);
          }
        }
      );
    },

    /********************************** 点击事件*/
    itemClick(executeId) {
      var param = {'executeId': executeId};
      navigator.open("", 'run/HRunInfoz', param);
    },
  },
};
</script>


<style src="@/_css/style.css"></style>
<style scoped>
.bg {
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 9;
}
.line {
  height: 1px;
  margin-left: 40px;
}
.image-arrow {
  width: 16px;
  height: 22px;
  margin-left: 80px;
}

/*********************** 标题*/
.title {
  flex-direction: row;
  align-items: center;
  height: 100px;
  padding-left: 40px;
  padding-right: 136px; /*80 + 16 + 40*/
}

/*********************** 列表*/
.list {
  flex: 1;
}
.cell {
  flex-direction: row;
  align-items: center;
  height: 100px;
  padding-left: 40px;
  padding-right: 40px;
}

/*********************** 刷新*/
.refresh {
  width: 750;
  flex-direction: row;
  justify-content: center;
}
.load {
  margin-top: 16px;
  height: 40px;
  width: 40px;
}
.genduo-bg {
  flex-direction: row;
  justify-content: center;
  align-items: center;
  width: 750px;
  height: 100px;
}
</style>